
// 283.移动零
class Solution {
public:
    void moveZeroes(vector<int>& nums) {
        // 使用双指针来解决
        int n = nums.size();
        int prev = 0 , count = 0;
        for(int i = 0; i < n ; i++)
            if(nums[i] != 0) nums[prev++] = nums[i];
            else count++;
        for(int i = n - count ; i < n ; i++) nums[i] = 0;
    }
};